//格式化时间戳
function formatTime(ns)
{
	if(!ns || ns == 'null' || ns == '')
		return '';
	
	var time = new Date(ns);
	var y = time.getFullYear();
	var m = time.getMonth()+1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	
	return y+'-'+addZero(m)+'-'+addZero(d)+' '+addZero(h)+':'+addZero(mm)+':'+addZero(s);
}

//格式化时间戳
function formatTimeToDay(ns)
{
	if(!ns || ns == 'null' || ns == '')
		return '';
	
	var time = new Date(ns);
	var y = time.getFullYear();
	var m = time.getMonth()+1;
	var d = time.getDate();
	
	return y+'-'+addZero(m)+'-'+addZero(d);
}

function addZero(m)
{	
	return m < 10 ? '0' + m:m; 
}

//格式化金额
function formatMoney(num) 
{
	if(num == 'null' || num == '')
		return '';
	
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*10+0.50000000001);
	cents = num%10;
	num = Math.floor(num/10).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	if(cents > 0) 
		return (((sign)?'':'-') + num + '.' + cents);
	return (((sign)?'':'-') + num);
}